/**
 * 
 */
package com.gr.staffpm.widget.jqgrid.component.event;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;

import com.gr.staffpm.datatypes.TaskQueue;
import com.gr.staffpm.pages.management.review.TaskReviewPage;


/**
 * @author Graham Rhodes 17 Jan 2011 14:17:49
 */
public class OnTaskQueueSelectRowAjaxEvent extends OnSelectRowAjaxEvent<TaskQueue> {

    private static final long serialVersionUID = 1L;
    private final TaskReviewPage reviewpage;

    public OnTaskQueueSelectRowAjaxEvent(TaskReviewPage reviewpage) {
        this.reviewpage = reviewpage;
    }

    /* (non-Javadoc)
     * @see com.gr.staffpm.widget.jqgrid.component.event.OnSelectRowAjaxEvent#onSelectRow(org.apache.wicket.ajax.AjaxRequestTarget, int, org.apache.wicket.model.IModel, boolean)
     */
    @Override
    protected void onSelectRow(AjaxRequestTarget target, int row, IModel<TaskQueue> rowModel, boolean status) {
        if (status && !reviewpage.getSelectedQueuedTaskModels().contains(rowModel))
            reviewpage.getSelectedQueuedTaskModels().add(rowModel);
        else if (!status && reviewpage.getSelectedQueuedTaskModels().contains(rowModel)) {
            reviewpage.getSelectedQueuedTaskModels().remove(rowModel);
        }

    }

}
